package wsz;

import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.context.annotation.*;

/**
 * @author wsz
 * @date 2021/12/10 19:29
 **/
public class ConsumerTest {
    public static void main(String[] args) throws Exception {
        AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConf.class);
        context.start();

        UserService userService = context.getBean(UserService.class);

        while (true) {
            System.in.read();
            try {
                String sayHello = userService.sayHello("wsz");
                System.out.println("result:" + sayHello);
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    }
    @Configuration
    @EnableDubbo(scanBasePackages = "wsz.service")
    @PropertySource("classpath:/dubbo-consumer.properties")
    @ComponentScan(value = {"wsz.service"})
    static class ProviderConf {
        @Bean
        public RegistryConfig registryConfig() {
            RegistryConfig registryConfig = new RegistryConfig();
            registryConfig.setAddress("zookeeper://127.0.0.1:2181");
            return registryConfig;
        }
    }
}
